﻿using Equation.Enterprise.Framework.Domain.Model;
using Equation.Enterprise.Tests.Framework.Domain.Model;

namespace Equation.Enterprise.Framework.Tests.Domain.Data.Mapping
{
    public class ProductMapping : EntityMapping<Product>
    {
        public ProductMapping() : base("Product")
        {
            Property(x => x.Id).HasColumnName("ProductId");
            HasRequired(x => x.Category).WithMany(x => x.Products).Map(x => x.MapKey("CategoryId"));
            HasMany(x=>x.Orders).WithMany(x=>x.Products).Map(x=>
                                                                 {
                                                                     x.MapLeftKey("ProductId");
                                                                     x.MapRightKey("OrderId");
                                                                     x.ToTable("ProductOrder");
                                                                 });
        }
    }
}
